package com.yl.auth.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.easyexcel.listener.ExcelQianZaiKeHuDTOListener;
import com.yl.auth.model.entity.ExcelDictDTO;
import com.yl.auth.model.entity.ExcelQianZaiDTO;
import com.yl.auth.model.entity.Laoren;
import com.yl.auth.model.entity.QianZaiKeHu;
import com.yl.auth.mapper.QianZaiKeHuMapper;
import com.yl.auth.model.vo.QianZaiKeHuVo;
import com.yl.auth.service.QianZaiKeHuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yl
 * @since 2023-06-29
 */
@Slf4j
@Service
public class QianZaiKeHuServiceImpl extends ServiceImpl<QianZaiKeHuMapper, QianZaiKeHu> implements QianZaiKeHuService {

    @Resource
    private QianZaiKeHuMapper qianZaiKeHuMapper;

    @Override
    public Page<QianZaiKeHu> findAll(Page<QianZaiKeHu> page1, QianZaiKeHuVo qianZaiKeHuVo) {
        return qianZaiKeHuMapper.findAll(page1,qianZaiKeHuVo);
    }

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public void improtData(InputStream inputStream) {
        //这里需要指定读用哪个class去读.然后读取第一个sheet文件流会自动关闭
        EasyExcel.read(inputStream, ExcelQianZaiDTO.class,new ExcelQianZaiKeHuDTOListener(baseMapper)).sheet().doRead();
        log.info("improtData finished");
    }
}
